package cn.seapon.talker.fragments;

import java.util.ArrayList;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.OnChildClickListener;
import cn.seapon.talker.ChatActivity;
import cn.seapon.talker.R;
import cn.seapon.talker.adapters.FriendListAdapter;
import cn.seapon.talker.common.FriendListInfomation.FriendInfomation;
import cn.seapon.talker.common.GroupInfo;

/** 
 * @author 作者 E-mail: 
 * @version 创建时间：2015年1月2日 下午2:09:41 
 * 类说明 
 */
public class FriendListFragment extends TalkerBasedFragment{

	private static final String TAG = "联系人";
	//数据
	private ArrayList<FriendInfomation> friendEntities = new ArrayList<FriendInfomation>();
	private GroupInfo froupInfo;
	//内容
	private View contentView;
	private ExpandableListView friendList;
	
	public FriendListFragment(Context context, String content) {
		super(context, content);
		this.content = content;
		this.context = context;
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
		contentView = inflater.inflate(R.layout.fragment_friendlist, container, false);
		friendList = (ExpandableListView) contentView.findViewById(R.id.expandable_friendlist);

		initData();
		return contentView;
	}

	@Override
	public void onResume() {
		toastShow(TAG+"获得了焦点了");
		super.onResume();
	}

	@Override
	protected void initData() {
        final FriendListAdapter mAdapter = new FriendListAdapter(context);
        friendList.setAdapter(mAdapter);
		friendList.setOnChildClickListener(new OnChildClickListener() {			
			@Override
			public boolean onChildClick(ExpandableListView parent, View v,int groupPosition, int childPosition, long id) {
				FriendInfomation entity = (FriendInfomation) v.getTag();
//				toastShow(entity.getNickname());
				Intent intent = new Intent(context,ChatActivity.class);
				intent.putExtra("friendEntity", entity);
				startActivity(intent);
				return true;
			}
		});
	}

	@Override
	protected void initView() {
	}

	@Override
	public String getTitile() {
		return TAG;
	}


	

}
